-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle implicits with default parameters. #1073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/rebuild |
The first commit in this PR was a merge commit which is confusing, I've fixed that and push-forced |
acc += arg | ||
argsOrError(pnames1, ptypes1, acc) | ||
case ambi: AmbiguousImplicits => | ||
() => s"ambiguous implicits: ${ambi.explanation} of $where" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply return a String?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we do not want to incur the cost of constructing it when the error does not get reported. Error strings are always lazy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, intuitively I'd think that the cost of creating a closure would be higher than the cost of constructing a String
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly not if the string is interpolated.
This doesn't work for implicit parameter lists where only some of the parameters have default values: class A
object Impl {
def foo()(implicit ev: Int, x: A = null): Int = 2
def test: Int = {
implicit val ii: Int = 1
foo()
}
} stack trace: https://gist.github.com/smarter/40c990590e42be4b28f5 |
If an implicit parameter has a default, then that default should be taken in case no implicit argument is found.
Now also handles mixed lists where some implicits have defaults and others don't. |
I am going to merge because I have to touch this code again for the classtags issue and I don't want to be slowed down with merging the two fixes afterwards. |
Handle implicits with default parameters.
Fixes #576.
run/pending/Meter now compiles; crashes at runtime.
Review by @smarter.